package com.sg.business.commons.labelprovider.work;

import org.eclipse.swt.graphics.Image;

import com.mobnut.commons.util.file.FileUtil;
import com.sg.business.model.Deliverable;
import com.sg.business.model.Document;
import com.sg.business.resource.BusinessResource;
import com.sg.widgets.commons.labelprovider.ConfiguratorColumnLabelProvider;

public class WorkEditDocHtmlLabel extends ConfiguratorColumnLabelProvider {

	@Override
	public String getText(Object element) {
		StringBuffer sb = new StringBuffer();
		if (element instanceof Deliverable) {
			Deliverable deliverable = (Deliverable) element;
			Document document = deliverable.getDocument();
			if (document != null) {
				sb.append("<img src='"); //$NON-NLS-1$
				sb.append(FileUtil.getImageURL(
						BusinessResource.IMAGE_EDIT_C_16,
						BusinessResource.PLUGIN_ID,
						BusinessResource.IMAGE_FOLDER));
				sb.append("' style='cursor:pointer;border-style:none;position:absolute; left:0; top:0; display:block;' width='16' height='16' /> "); //$NON-NLS-1$
			}
		}

		return sb.toString();
	}

	@Override
	public Image getImage(Object element) {
		// if (element instanceof Deliverable) {
		// Deliverable deliverable = (Deliverable) element;
		// Document document = deliverable.getDocument();
		// if (document != null
		// && document.canEdit(new CurrentAccountContext())) {
		// return BusinessResource
		// .getImage(BusinessResource.IMAGE_EDIT_C_16);
		// }
		// }
		return null;
	}

}
